package com.tanhua.admin.controller;

import com.tanhua.admin.service.ManageService;
import com.tanhua.dubbo.api.UserInfoApi;
import com.tanhua.model.domain.UserInfo;
import com.tanhua.model.vo.MovementsVo;
import com.tanhua.model.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/manage")
public class ManageController {

    @Autowired
    private ManageService manageService;

    //查询所有用户信息
    @GetMapping("/users")
    public ResponseEntity users(@RequestParam(defaultValue = "1") Integer page,
                                @RequestParam(defaultValue = "10") Integer pagesize){
       PageResult pr =  manageService.fandAll(page,pagesize);
       return ResponseEntity.ok(pr);
    }
    //查询个人用户信息
    @GetMapping("/users/{userId}")
    public ResponseEntity findUserById(@PathVariable Long userId){
      UserInfo userInfo =  manageService.finUserById(userId);
        return  ResponseEntity.ok(userInfo);
    }
    //查询个人视频列表
    @GetMapping("/videos")
    public ResponseEntity videos(@RequestParam(defaultValue = "1") Integer page,
                                 @RequestParam(defaultValue = "10") Integer pagesize,Long uid){
        PageResult pr =   manageService.findByIdVideos(page,pagesize,uid);
        return ResponseEntity.ok(pr);
    }
    //查询个人动态
    @GetMapping("/messages")
    public ResponseEntity messages(@RequestParam(defaultValue = "1") Integer page,
                                   @RequestParam(defaultValue = "10") Integer pagesize,
                                   Long uid,Integer state){
        PageResult result = manageService.findAllMovements(page,pagesize,uid,state);
        return ResponseEntity.ok(result);
    }

    //详细动态
    @GetMapping("/messages/{id}")
    public ResponseEntity messages(@PathVariable String id){
      MovementsVo vo =  manageService.findByidMovements(id);
      return ResponseEntity.ok(vo);
    }

    //分页查询评论列表
    @GetMapping("/messages/comments")
    public ResponseEntity comments(@RequestParam(defaultValue = "1") Integer page,
                                   @RequestParam(defaultValue = "10") Integer pagesize,
                                   String messageID) {
        PageResult result = manageService.findmessageID(page, pagesize, messageID);
        return ResponseEntity.ok(result);
    }
}

